package com.example.kafkaboot.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.config.TopicBuilder;
import org.springframework.kafka.support.converter.BatchMessagingMessageConverter;
import org.springframework.kafka.support.converter.RecordMessageConverter;
import org.springframework.kafka.support.converter.StringJsonMessageConverter;

/**
 * @author cxx
 * @create 2020-03-30 15:51
 **/
@Configuration
public class KafkaConfiguration {

    @Bean
    public NewTopic userTopic(){
        return TopicBuilder.name ("test.user").replicas (2).partitions (3).build ();
    }

    @Bean
    public RecordMessageConverter converter() {
        return new StringJsonMessageConverter ();
    }

    @Bean
    public BatchMessagingMessageConverter batchConverter() {
        return new BatchMessagingMessageConverter(converter());
    }

}
